from python_basic.common.xcommon import sep


class Student(object):

    def __init__(self, id, name):
        self.__id = id
        self.__scores = {}
        self.__name = name

    def __del__(self):
        print(f'Destructing Student "{self.__name}" with id {self.__id}')

    def __str__(self):
        return f'{{ Student: "{self.__name}" with id {self.__id} with scores: {self.__scores} }}'

    def get_scores(self):
        return self.__scores

    def set_scores(self, subject, score):
        self.__scores[subject] = score


if '__main__' == __name__:
    sep(label='xiaoer')
    xiaoer = Student('12345678', '小二')
    print(xiaoer)
    xiaoer.set_scores('English', 67)
    xiaoer.set_scores('Computer', 88.88)
    print(xiaoer.get_scores())
    'By decorator:'
    print(xiaoer)

    sep(label='End of testing Student')
